package com.charley.icloud.common.response.result;

import com.charley.icloud.common.response.code.BackAdminSysCode;
import com.charley.icloud.common.response.code.HttpStatus;

public class HttpResponseResultFactory {

    /**
     * 构建一个通用的成功的返回结果
     */
    public static HttpResponseResult buildHttpResponseResult() {
        return new HttpResponseResult(BackAdminSysCode.ICLOUD_SYSTEM_SUCCESS_CODE, BackAdminSysCode.ICLOUD_SYSTEM_SUCCESS_MSG);
    }

    public static HttpResponseResult buildHttpResponseResult(String resultCode) {
        return new HttpResponseResult(resultCode);
    }

    public static HttpResponseResult buildHttpResponseResult(String resultCode, String resultMsg) {
        return new HttpResponseResult(resultCode, resultMsg);
    }

    public static HttpResponseResult buildHttpResponseResult(String resultCode, Object obj) {
        return new HttpResponseResult(resultCode, obj);
    }

    public static HttpResponseResult buildHttpResponseResult(String resultCode, String resultMsg, Object obj) {
        return new HttpResponseResult(resultCode, resultMsg, obj);
    }

    public static HttpResponseResult success(Object obj) {
        HttpResponseResult httpResponseResult = new HttpResponseResult();
        httpResponseResult.setResultCode(HttpStatus.SC_OK)
                .setResultMsg(HttpStatus.SC_OK_MSG)
                .setData(obj);
        return httpResponseResult;
    }

    public static HttpResponseResult fail(String failMsg) {
        HttpResponseResult httpResponseResult = new HttpResponseResult();
        httpResponseResult.setResultCode(HttpStatus.SC_BAD_REQUEST)
                .setResultMsg(failMsg);
        return httpResponseResult;
    }

    public static HttpResponseResult fail(String failMsg, Object obj) {
        HttpResponseResult httpResponseResult = new HttpResponseResult();
        httpResponseResult.setResultCode(HttpStatus.SC_BAD_REQUEST)
                .setResultMsg(failMsg)
                .setData(obj);
        return httpResponseResult;
    }

    public static HttpResponseResult fail(String failMsg, String resultCode) {
        HttpResponseResult httpResponseResult = new HttpResponseResult();
        httpResponseResult.setResultCode(resultCode)
                .setResultMsg(failMsg);
        return httpResponseResult;
    }
}
